package com.okaysoft.ofb

class Device {

    String name  //名称
    Area area   //片区
    Location location
    String logo
    String code   //代码
    String description
    String model//型号
    String factory //厂家
    Capacity capacity//容量
    Status status//状态
    Mode mode//安装方式
    Date date//安装时间
    Formwork formwork//模板

    static embedded = ['location', 'capacity']

    static constraints = {
        location(nullable: true)
        capacity(nullable: true)
        description(nullable: true)
        formwork(nullable: true)
        date(nullable: true)
        model(nullable: true)
        factory(nullable: true)
        status(nullable: true)
        mode(nullable: true)
        logo(nullable: true,unique: true)
        code(unique: true)

    }

    enum Status {
        ENABLED(0, '使用'),
        SERVICE(1, '维修'),
        SCRAPPED(2, '报废')
        String label
        int id
        Status (int id, String label) {
            this.id = id
            this.label = label
        }
    }

    enum Mode {
        OUTDOOR_GROUND(0, '室外落地') ,
        OUTDOOR_OVERHEAD(1, '室外架空') ,
        WALL(2, '壁挂') ,
        INDOOR(3, '室内')
        String label
        int id

        Mode(int id, String label) {
            this.id = id
            this.label = label
        }
    }

}

class Location {
    String addr   //地址
    String latitude // 纬度
    String longitude //经度
    String installation //安装位置

    static constraints = {
        addr(nullable: true)
        latitude (nullable: true)
        longitude(nullable: true)
        installation(nullable: true)
    }
}

class Capacity{
    String nominal //标称
    String actual  //实际

    static constraints = {
        nominal nullable: true
        actual nullable: true
    }
}
